#ifndef SHTO_UTILITY_H
#define SHTO_UTILITY_H

#include "defines.h"

namespace ShTo {

class Utility
{
public:
    /**
     * List directories or files in a directory
     *
     * @param psPath the specified directory
     * @param zList the result
     * @param iMode 0 both
     *              1 directory only
     *              2 file only
     * @param bFull true the fullname
     *              false only the name
     * @return true if success, false otherwise
     */
     static bool ls(const char* psPath, List<std::string>::Type& zList, int iMode = 0, bool bFull = false);

     /**
      * Test the given path is a directory
      *
      * @param psPath the given path
      * @return true if it is a directory, false otherwise
      */
     static bool isDir(const char* psPath);

     /**
      * Make a directory given by path recursively
      * @param psPath the given path
      * @return true if success, false otherwise
      */
     static bool mkDir(const char* psPath);

     /**
      * Remove a directory whether it's empty or not
      *
      * @param psPath the given path
      * @return true if success, false otherwise
      */
     static bool rmDir(const char* psPath);

     /**
      * Move the directory to another location
      *
      * @param psPath the directory to be moved
      * @param psDest the destination path
      * @return true if success, false otherwise
      */
     static bool mvDir(const char* psPath, const char* psDest);

     /**
      * Copy the directory to another location
      *
      * @param psPath the directory to be copied
      * @param psDest the destination path
      * @return true if success, false otherwise
      */
     static bool cpDir(const char* psPath, const char* psDest);

     /**
      * Test the given path is a file or not
      *
      * @param psPath the given file path
      * @return true if it's a file, false otherwise
      */
     static bool isFile(const char* psPath);

     /**
      * Remove a file
      *
      * @param psPath the file to be removed
      * @return true if success, false otherwise
      */
     static bool rmFile(const char* psPath);

     /**
      * Move a file to another location
      *
      * @note if the destination file exists, overwrite it
      *
      * @param psPath the file to be moved
      * @param psDest the destination
      * @return true if success, false otherwise
      */
     static bool mvFile(const char* psPath, const char* psDest);

     /**
      * Copy a file to another location
      *
      * @note if the destination file exists, overwrite it
      *
      * @param psPath the file to be copied
      * @param psDest the destination
      * @return true if success, false otherwise
      */
     static bool cpFile(const char* psPath, const char* psDest);

     static bool uTF8ToAStr(const std::string& U, std::string& A);
     static bool aStrToUTF8(const std::string& A, std::string& U);
     static bool uTF8ToAStr(const List<char>::Type& U, List<char>::Type& A);
     static bool aStrToUTF8(const List<char>::Type& A, List<char>::Type& U);

     static List<std::string>::Type split(const std::string& S, const std::string& D, int M = 0);
};

} // namespace ShTo

#endif // SHTO_UTILITY_H
